﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.CompositeUI.Services;
using Microsoft.Practices.CompositeUI.UIElements;
using WPFCABShell.$safeprojectname$.Interface.Services.Command;
using WPFCABShell.$safeprojectname$.Interface.Services.Menu;
using WPFCABShell.$safeprojectname$.Interface.Services.Options;
using WPFCABShell.$safeprojectname$.Interface.Services.Skinning;
using WPFCABShell.$safeprojectname$.Interface.Services.StatusBar;
using WPFCABShell.$safeprojectname$.Interface.Services.ToolBar;
using WPFCABShell.$safeprojectname$.Interface.Services.Settings;
using WPFCABShell.$safeprojectname$.Services;
using WPFCABShell.$safeprojectname$.Services.Command;
using WPFCABShell.$safeprojectname$.Services.Menu;
using WPFCABShell.$safeprojectname$.Services.Module;
using WPFCABShell.$safeprojectname$.Services.Options;
using WPFCABShell.$safeprojectname$.Services.Skinning;
using WPFCABShell.$safeprojectname$.Services.StatusBar;
using WPFCABShell.$safeprojectname$.Services.ToolBar;
using WPFCABShell.$safeprojectname$.Services.Settings;

namespace WPFCABShell.$safeprojectname$
{
	/// <summary>
	/// Implements the entry point for the application.
	/// </summary>
	internal sealed class Entry : SCSFContrib.CompositeUI.WPF.ApplicationShellApplication<RootWorkItem, App>
	{
		[STAThread]
		internal static void Main()
		{
			new Entry().Run();
		}

		protected override void AddServices()
		{
			base.AddServices();

			//add the core services provided by this shell
			RootWorkItem.Services.AddNew<IsolatedStorageSettingsService, ISettingsService>();
			RootWorkItem.Services.AddNew<CommandService, ICommandService>();
			RootWorkItem.Services.AddNew<MenuService, IMenuService>();
			RootWorkItem.Services.AddNew<OptionsService, IOptionsService>();
			RootWorkItem.Services.AddNew<SkinningService, ISkinningService>();
			RootWorkItem.Services.AddNew<StatusBarService, IStatusBarService>();
			RootWorkItem.Services.AddNew<ToolBarService, IToolBarService>();

			//use a custom module enumerator to facilitate a plugin model
			RootWorkItem.Services.Remove<IModuleEnumerator>();
			RootWorkItem.Services.AddNew<WhitelistModuleEnumerator, IModuleEnumerator>();

			//use a specialized ItemsControl adapter that supports grouping of items (and automatically
			//inserts separators where necessary)
			IUIElementAdapterFactoryCatalog uiElementAdapterFactoryCatalog = RootWorkItem.Services.Get<IUIElementAdapterFactoryCatalog>();
			uiElementAdapterFactoryCatalog.RegisterFactory(new GroupingItemsControlUIAdapterFactory());
			//an adapter for the ToolBarTray
			uiElementAdapterFactoryCatalog.RegisterFactory(new ToolBarTrayUIAdapterFactory());
		}
	}
}
